package com.cjj.refresh;


import ohos.agp.render.Paint;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/8/31.
 */
public class Rain implements Cloneable {
    private Paint paint;
    private float speedY;
    private float speedX;
    private float xPoint;
    private float yPoint;
    private float wPoint;
    private float pos;

    /**
     * getPaint
     *
     * @return Paint
     */
    public Paint getPaint() {
        return paint;
    }

    /**
     * setPaint
     *
     * @param paint paint
     */
    public void setPaint(Paint paint) {
        this.paint = paint;
    }

    /**
     * getwPoint
     *
     * @return float
     */
    public float getwPoint() {
        return wPoint;
    }

    /**
     * setwPoint
     *
     * @param wPoint wPoint
     */
    public void setwPoint(float wPoint) {
        this.wPoint = wPoint;
    }

    /**
     * getX
     *
     * @return float
     */
    public float getX() {
        return xPoint;
    }

    /**
     * setX
     *
     * @param x1 x1
     */
    public void setX(float x1) {
        this.xPoint = x1;
    }

    /**
     * getyPoint
     *
     * @return float
     */
    public float getyPoint() {
        return yPoint;
    }

    /**
     * setyPoint
     *
     * @param yPoint yPoint
     */
    public void setyPoint(float yPoint) {
        this.yPoint = yPoint;
    }

    /**
     * getSpeedY
     *
     * @return float
     */
    public float getSpeedY() {
        return speedY;
    }

    /**
     * setSpeedY
     *
     * @param speedY speedY
     */
    public void setSpeedY(float speedY) {
        this.speedY = speedY;
    }

    /**
     * getSpeedX
     *
     * @return float
     */
    public float getSpeedX() {
        return speedX;
    }

    /**
     * setSpeedX
     *
     * @param speedX speedX
     */
    public void setSpeedX(float speedX) {
        this.speedX = speedX;
    }

    /**
     * getPos
     *
     * @return float
     */
    public float getPos() {
        return pos;
    }

    /**
     * setPos
     *
     * @param pos pos
     */
    public void setPos(float pos) {
        this.pos = pos;
    }

    @Override
    protected Rain clone() throws CloneNotSupportedException {
        Rain rain = null;
        try {
            rain = (Rain) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return rain;
    }

    /**
     * clone
     *
     * @param number number
     * @return List<Rain>
     */
    public List<Rain> clone(int number) {
        List<Rain> clones = null;
        Rain clone;
        try {
            clones = new ArrayList<>();
            for (int i = 0; i < number; i++) {
                clone = clone();
                clone.getPaint().setStrokeWidth(
                        (float) (new SecureRandom().nextDouble() * ((double) clone.getwPoint() - 1) + 1));
                clone.setX((float) (new SecureRandom().nextInt() * (double) getPos()));
                clones.add(clone);
            }
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return clones;
    }
}
